//Plugin for hey0 mod v107 that adds additional logging information to the server.log
//also informs mods (and minimods) when these are used
//Originally written by poemdexter
//http://code.google.com/p/poempack/
//
//Modifications added by ehushagen:
// - graceful plugin disabling
// - support for Penislandia's "minimods" group

import java.util.List;
import java.util.logging.Logger;

public class poemLogger extends Plugin {

    protected static final Logger log = Logger.getLogger("Minecraft");
    static final poemLoggerListener listener = new poemLoggerListener();
    
    public void enable() {
        log.info("poemLoggerEHMod plugin enabled");
        etc.getInstance().addCommand("/respond", " [x][y][z] - teleports to location");
        tellMods("poemLoggerEHMod plugin enabled");
    }

    public void disable() {
        log.info("poemLoggerEHMod plugin disabled");
        etc.getInstance().removeCommand("/respond");
        tellMods("poemLoggerEHMod plugin disabled");
    }

    public void initialize() {
        etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.MEDIUM);
        etc.getLoader().addListener(PluginLoader.Hook.BLOCK_CREATED, listener, this, PluginListener.Priority.MEDIUM);
    }

    public void tellMods(String message) {
        List<Player> pList = etc.getInstance().getServer().getPlayerList();
        for (Player p : pList) {
            if (p.isInGroup("mods")) {
                p.sendMessage(Colors.Rose + message);
            }
            if (p.isInGroup("minimods")) {
                p.sendMessage(Colors.Rose + message);
            }
        }
    }
}
